define(["jquery"], function($) {
	// 构造函数
	function Header() {
		this.createDom();
		this.genTime();
//		this.loadUser();
//		this.addListener();
	}

	// 头部布局的模板
	Header.headerTemplate = `<nav class="navbar navbar-default">
		  <div class="container-fluid">
		    <div class="navbar-header">
		      <a class="navbar-brand" href="#">
		        <img alt="Brand" src="../images/images/buy.png">
		      </a>
		      <p class="navbar-text">超市账单管理系统</p>
		    </div>
		    <button type="button" class="btn btn-default navbar-btn navbar-right">退出</button>
			    <ul class="nav navbar-nav navbar-right not-login">
			        <li data-toggle="modal" data-target="#loginModal"><a href="/">登录</a></li>
			    </ul>
			    <ul class="nav navbar-nav navbar-right hidden already-login">
			       <li><a href="#" class="link-username">你好</a></li>
			    </ul>  
		  </div>
		</nav>
		<div class="container-fluid">
			<div class="row">
			    <div class="col-md-4" id="time"></div>
			    <div class="col-md-4 col-md-offset-4 text-right">温馨提示:为了能够正常浏览,请使用高版本浏览器!(IE10+)</div>
		    </div>
	    </div>`;

	// 原型
	$.extend(Header.prototype, {
//		 创建头部所使用到的DOM节点
		createDom() {
			$(Header.headerTemplate).appendTo("header");
			setInterval(()=>{
				this.genTime();
			},1000)
		},
		genTime(){
			var time = new Date();     
			var year = time.getFullYear();
			var month = time.getMonth() + 1;
			var date = time.getDate();
			var hours = time.getHours();
			var minutes = time.getMinutes();
			var seconds = time.getSeconds();
			var day = time.getDay();
			if(month < 10){
				month = "0" + month;
			}
			if(date < 10){
				date = "0" + date;
			}
			if(hours < 10){
				hours = "0" + hours;
			}
			if(minutes < 10){
				minutes = "0" + minutes;
			}
			if(seconds < 10){
				seconds = "0" + seconds;
			}
			
			var t = year+"年"+month+"月"+date+"日"+hours+":"+minutes+":"+seconds+" "+"星期"+"日一二三四五六".charAt(day);
			$("#time").text(t)
		}
	});

	return new Header();
});